Clean up linker flag definitions.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 18 Oct 2006 15:56:27 +0000 (16:56 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 18 Oct 2006 15:56:27 +0000 (16:56 +0100)
 1. GNU ld does not understand -m{32,64}. It must be cooked for it by
    the GCC driver program.
 2. Where GNU ld is directly called we must use -melf_{i386,x86_64}.
 3. We cannot avoid calling GNU ld directly in some cases (e.g., when
    specifying GNU-specific linker scripts) as on some host
    architectures the GCC driver is configured to call the host
    linker.
 4. We cannot add -melf_{i386,x86_64} to LDFLAGS as the option is
    not recognised by GCC.

Hence we define new LDFLAGS_DIRECT, to be added to the command line
only when invoking GNU ld directly.

Signed-off-by: Keir Fraser <keir@xensource.com>
config/x86_32.mk
config/x86_64.mk
tools/firmware/hvmloader/Makefile
tools/firmware/vmxassist/Makefile
xen/Rules.mk
xen/arch/x86/Rules.mk

index 4db3c73b3b0babaf26636ac975bc9d123a619539..7e13463326cb16851d7a9c7bb769f08f3a22753c 100644 (file)
@@ -7,5 +7,7 @@ CONFIG_XCUTILS := y
 CONFIG_IOEMU := y
 
 CFLAGS += -m32 -march=i686
-LDFLAGS += -m32
 LIBDIR := lib
+
+# Use only if calling $(LD) directly.
+LDFLAGS_DIRECT += -melf_i386
index c76567563c5bea24bc346339ed398ccc0fd6bd6d..3825caafd5bf98ee6f63276f853f0bbf6ed168b3 100644 (file)
@@ -7,5 +7,7 @@ CONFIG_XCUTILS := y
 CONFIG_IOEMU := y
 
 CFLAGS += -m64
-LDFLAGS += -m64
 LIBDIR = $(LIB64DIR)
+
+# Use only if calling $(LD) directly.
+LDFLAGS_DIRECT += -melf_x86_64
index 3f9b7a95bb427363a4abde6e8b9b550e8cc71a82..ae031e96d497a300be02bd0d6aa4543f0dbfeebd 100644 (file)
@@ -38,7 +38,7 @@ CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
 
 OBJCOPY  = objcopy
 CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
-LDFLAGS  = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
+LDFLAGS  = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
 
 SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c
 OBJS = $(patsubst %.c,%.o,$(SRCS))
@@ -48,7 +48,7 @@ all: hvmloader
 
 hvmloader: roms.h $(SRCS)
        $(CC) $(CFLAGS) -c $(SRCS)
-       $(CC) $(LDFLAGS) -o hvmloader.tmp $(OBJS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o hvmloader.tmp $(OBJS)
        $(OBJCOPY) hvmloader.tmp hvmloader
        rm -f hvmloader.tmp
 
index 08fea457817a5e5d5750943cc4e1f91db652e53c..1f441a12c38c3d8c04dfc253e88c56a2e27eb1b7 100644 (file)
@@ -39,7 +39,6 @@ CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
 CPP      = cpp -P
 OBJCOPY  = objcopy -p -O binary -R .note -R .comment -R .bss -S --gap-fill=0
 CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
-LDFLAGS  = -m elf_i386
 
 OBJECTS = head.o trap.o vm86.o setup.o util.o
 
@@ -48,7 +47,7 @@ all: vmxassist.bin
 
 vmxassist.bin: vmxassist.ld $(OBJECTS)
        $(CPP) $(DEFINES) vmxassist.ld > vmxassist.tmp
-       $(LD) -o vmxassist $(LDFLAGS) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS)
+       $(LD) -o vmxassist $(LDFLAGS_DIRECT) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS)
        nm -n vmxassist > vmxassist.sym
        $(OBJCOPY) vmxassist vmxassist.tmp
        dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
index 1522ba786bc19b32b7519b1b6117b9f2e0cc4426..d333e563ce76b6ce18c7812e0c36bcf3043a6726 100644 (file)
@@ -71,6 +71,9 @@ CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
 AFLAGS   := $(strip $(AFLAGS) $(AFLAGS-y))
 AFLAGS   += $(patsubst -std=gnu%,,$(CFLAGS))
 
+# LDFLAGS are only passed directly to $(LD)
+LDFLAGS  += $(LDFLAGS_DIRECT)
+
 include Makefile
 
 # Ensure each subdirectory has exactly one trailing slash.
index 176d6aebf415b7adf46542940ffe286d120b82f8..33eb5b53a4e945aaf6051995d23bb1c62c63f2df 100644 (file)
@@ -34,7 +34,6 @@ CFLAGS  += -DCONFIG_X86_SUPERVISOR_MODE_KERNEL=1
 endif
 
 ifeq ($(XEN_TARGET_ARCH),x86_32)
-LDFLAGS += -m elf_i386
 x86_32 := y
 x86_64 := n
 endif
@@ -45,7 +44,6 @@ CFLAGS  += -fno-asynchronous-unwind-tables
 # -fvisibility=hidden reduces -fpic cost, if it's available
 CFLAGS  += $(shell $(CC) -v --help 2>&1 | grep " -fvisibility=" | \
              grep -q hidden && echo "-DGCC_HAS_VISIBILITY_ATTRIBUTE")
-LDFLAGS += -m elf_x86_64
 x86_32 := n
 x86_64 := y
 endif